package me.zogodo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.awt.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

import org.patchca.color.SingleColorFactory;
import org.patchca.filter.predefined.CurvesRippleFilterFactory;
import org.patchca.service.ConfigurableCaptchaService;
import org.patchca.utils.encoder.EncoderHelper;

/**
 * Created by zogod on 2016/9/8.
 */
@WebServlet("/AServlet")
public class AServlet extends HttpServlet
{
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        request.setCharacterEncoding("UTF-8"); //表单有中文
        response.setContentType("text/html;charset=UTF-8"); //回复有中文

        PrintWriter out = response.getWriter();
        String usr = request.getParameter("username");

        //if (usr == "admin")
        if (usr.equals("admin"))
        {
            out.println(usr + " 正确。");
        }
        else
        {
            out.println(usr + " 错误！");
        }

        out.close();

        //SqlHelper.Select();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        String usr = request.getParameter("username");
        String paw = request.getParameter("password");

        PrintWriter out = response.getWriter();
        out.println("你好，世界！<br />");
        out.println(usr + " " + paw);

    }
}
